package com.ruoyi.monitor.infoprojectmonitorfunds.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.monitor.infoprojectmonitorfunds.domain.InfoProjectMonitorFunds;
import com.ruoyi.monitor.infoprojectmonitorfunds.mapper.InfoProjectMonitorFundsMapper;
import com.ruoyi.monitor.infoprojectmonitorfunds.service.IInfoProjectMonitorFundsService;
import com.ruoyi.monitor.infoprojectmonitorfunds.vo.InfoProjectMonitorFundsVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * 项目监控资金监控详情  Service业务层处理
 *
 * @author ruoyi
 * @date 2022-02-15
 */
@Service
public class InfoProjectMonitorFundsServiceImpl implements IInfoProjectMonitorFundsService {
    @Resource
    private InfoProjectMonitorFundsMapper infoProjectMonitorFundsMapper;

    /**
     * 查询项目监控资金监控详情
     *
     * @param id 项目监控资金监控详情  主键
     * @return 项目监控资金监控详情
     */
    @Override
    public InfoProjectMonitorFunds selectInfoProjectMonitorFundsById(Long id) {
        return infoProjectMonitorFundsMapper.selectInfoProjectMonitorFundsById(id);
    }

    /**
     * 查询项目监控资金监控详情  列表
     *
     * @param infoProjectMonitorFunds 项目监控资金监控详情
     * @return 项目监控资金监控详情
     */
    @Override
    public List<InfoProjectMonitorFunds> selectInfoProjectMonitorFundsList(InfoProjectMonitorFunds infoProjectMonitorFunds) {
        return infoProjectMonitorFundsMapper.selectInfoProjectMonitorFundsList(infoProjectMonitorFunds);
    }

    /**
     * 新增项目监控资金监控详情
     *
     * @param infoProjectMonitorFunds 项目监控资金监控详情
     * @return 结果
     */
    @Override
    public int insertInfoProjectMonitorFunds(InfoProjectMonitorFunds infoProjectMonitorFunds) {
        infoProjectMonitorFunds.setCreateTime(DateUtils.getNowDate());
        return infoProjectMonitorFundsMapper.insertInfoProjectMonitorFunds(infoProjectMonitorFunds);
    }

    /**
     * 修改项目监控资金监控详情
     *
     * @param infoProjectMonitorFunds 项目监控资金监控详情
     * @return 结果
     */
    @Override
    public int updateInfoProjectMonitorFunds(InfoProjectMonitorFunds infoProjectMonitorFunds) {
        infoProjectMonitorFunds.setUpdateTime(DateUtils.getNowDate());
        return infoProjectMonitorFundsMapper.updateInfoProjectMonitorFunds(infoProjectMonitorFunds);
    }

    /**
     * 批量删除项目监控资金监控详情
     *
     * @param ids 需要删除的项目监控资金监控详情  主键
     * @return 结果
     */
    @Override
    public int deleteInfoProjectMonitorFundsByIds(Long[] ids) {
        return infoProjectMonitorFundsMapper.deleteInfoProjectMonitorFundsByIds(ids);
    }

    /**
     * 删除项目监控资金监控详情  信息
     *
     * @param id 项目监控资金监控详情  主键
     * @return 结果
     */
    @Override
    public int deleteInfoProjectMonitorFundsById(Long id) {
        return infoProjectMonitorFundsMapper.deleteInfoProjectMonitorFundsById(id);
    }

    /**
     * 查询监控执行率和项目名称
     * @return
     */
    @Override
    public List<Map<String, Object>> findMonitorFundsAndProjectNames(InfoProjectMonitorFundsVo infoProjectMonitorFundsVo) {
       /* ArrayList<InfoProjectMonitorFundsVo> infoProjectMonitorFundsVos = new ArrayList<>();
        InfoProjectMonitorFunds infoProjectMonitorFunds = new InfoProjectMonitorFunds();
        List<InfoProjectMonitorFunds> infoProjectMonitorFundsList = infoProjectMonitorFundsMapper.selectInfoProjectMonitorFundsList(infoProjectMonitorFunds);
        for (InfoProjectMonitorFunds projectMonitorFunds : infoProjectMonitorFundsList) {
            InfoProjectMonitorFundsVo infoProjectMonitorFundsVo = new InfoProjectMonitorFundsVo();
            Long projectMonitorRelationId = projectMonitorFunds.getProjectMonitorRelationId();
            String projectName = infoProjectMonitorFundsMapper.findProjectNamesById(projectMonitorRelationId);
            BeanUtils.copyProperties(projectMonitorFunds,infoProjectMonitorFundsVo);
            infoProjectMonitorFundsVo.setProjectName(projectName);
            infoProjectMonitorFundsVos.add(infoProjectMonitorFundsVo);
        }*/
        return infoProjectMonitorFundsMapper.findMonitorFundsAndProjectNames(infoProjectMonitorFundsVo);
    }
}
